#!/usr/bin/env python
"""
# -*- coding: utf-8 -*-
# @Time    : 2020/9/24 21:23
# @Author  : AshJo
# @Desc    : 封装
# @Filename: encapsulation.py
# @Version : v1.0
"""

import hashlib


class User:
    def __init__(self, name, password):
        self.name = name
        self.__password = password  # 私有的实例变量/属性

    def __get_md5(self):    # 私有的绑定方法
        """
        获取md5
        :return: md5哈希值
        """
        md5 = hashlib.md5(self.name.encode('utf-8'))
        md5.update(self.__password.encode('utf-8'))
        return md5.hexdigest()

    def get_pwd(self):
        return self.__get_md5()  # 外部只能看不能改

    def change_pwd(self):  # 外部只能看可以按照规定的方法改
        pass

user1 = User('alex', '123')
print(user1.get_pwd())
